# -*- coding: utf-8 -*-
"""
@author: luhx
@file: business.py
@time: 2023/8/10 7:30
@desc: 业务逻辑的具体实现
"""
from highlow.dd_obj import HoldItem


class Business:
    def __init__(self, parent):
        self.parent = parent

    def has_position(self, hold_item: HoldItem, side: int) -> bool:
        """判断在对应的方向上是否有持仓，
        有则返回True,没有返回False"""
        if hold_item is None:
            return False
        if side == 1:
            return hold_item.long_position != 0
        elif side == -1:
            return hold_item.short_position != 0
        return False